<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="./../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="addProduct" binding="#{productManagerBean.loadAddRawMaterial}">
                    <p:panel id="addProduct" header="Add a Product">
                        <p:messages />
                        
                        <table border="0" width="100%">
                            <tr>
                                <td width="150px">Code:</td>
                                <td>
                                    <p:inputText id="code" label="Product Code" required="true" 
                                                 requiredMessage="Product code cannot be empty."
                                                 title="Code of the product."
                                                 value="#{productManagerBean.code}">
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="150px">Name:</td>
                                <td>
                                    <p:inputText id="name" label="Product Name" required="true" 
                                                 requiredMessage="Product name cannot be empty."
                                                 title="Name of the product."
                                                 value="#{productManagerBean.pName}">
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="150px">Price:</td>
                                <td>
                                    <p:inputText id="price" label="Price" required="true" 
                                                 requiredMessage="Price cannot be empty."
                                                 title="Price of the product."
                                                 value="#{productManagerBean.price}">
                                        <f:convertNumber minFractionDigits="2" />
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="150px">Weight (g):</td>
                                <td>
                                    <p:inputText id="weight" label="Weight" required="true" 
                                                 requiredMessage="Weight cannot be empty."
                                                 title="Weight of the raw material."
                                                 value="#{productManagerBean.weight}">
                                        <f:convertNumber type="number" />
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="150px">Capacity per Hour:</td>
                                <td>
                                    <p:inputText id="capacityPerHour" label="Capacity per Hour" required="true" 
                                                 requiredMessage="Production capacity cannot be empty."
                                                 title="Production capacity for the product."
                                                 value="#{productManagerBean.capacityPerHour}">
                                        <f:convertNumber type="number" />
                                    </p:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="150px">Description:</td>
                                <td>
                                    <p:inputTextarea id="description" label="Description" required="true" 
                                                     requiredMessage="Description cannot be empty."
                                                     title="Description of the product."
                                                     style="width:450px;height:75px;" 
                                                     value="#{productManagerBean.pDescription}">
                                    </p:inputTextarea>
                        
                                </td>
                            </tr>
                            <tr>
                                
                                <td colspan="2" align="center"><hr/>
                                    <p:commandButton id="btnAddProduct" value="Add Product"
                                                     ajax="true" title="Add a product."
                                                     update="addProduct"
                                                     actionListener="#{productManagerBean.addAProduct}"/>
                                    &nbsp;&nbsp;&nbsp;
                                    <p:commandButton id="btnBackFromAddProduct" value="Back"
                                                     immediate="true" ajax="true"
                                                     title="Go back to the previous page."
                                                     actionListener="#{productManagerBean.back}"/>
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
